package cn.scy.constant;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 是否枚举类
 *
 * @author scy
 */
@Getter
@AllArgsConstructor
public enum YesNoStatus {

    /**
     * 是
     */
    YES("是", "1"),

    /**
     * 否
     */
    NO("否", "0");

    private final String name;

    private final String value;

    public static YesNoStatus getStatusEnum(String value) {
        for (YesNoStatus status : YesNoStatus.values()) {
            if (StrUtil.equals(status.getValue(), value)) {
                return status;
            }
        }
        return null;
    }

    public static YesNoStatus formatStatusEnum(String name) {
        for (YesNoStatus status : YesNoStatus.values()) {
            if (StrUtil.equals(status.getName(), name)) {
                return status;
            }
        }
        return null;
    }

}
